package com.coding365.blog.controler;

import com.coding365.blog.dao.ArticleMapper;
import com.coding365.blog.entity.Article;
import com.coding365.blog.utils.PageInfoUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("")
public class ArticleController {

    @Autowired
    private ArticleMapper articleMapper;

    @GetMapping("/index")
    public String getArticleList(Integer pageNo, Integer pageSize, Model model){
        PageInfoUtil.startPage(pageNo,pageSize);
        List<Article> articleList = articleMapper.selectAllArticles();
        PageInfo<Article> pageInfo = PageInfoUtil.getResult(articleList);
        model.addAttribute("result",pageInfo);
        return "client/index";
    }


}
